home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / architecture / sparc / reg.h < prev   
C/C++ Source or Header  |  1994-10-03  |  7KB  |  285 lines

  1. /*    @(#)reg.h 1.16 92/04/28 SMI    */
  2.  
  3. /*
  4.  * Copyright (c) 1985 by Sun Microsystems, Inc.
  5.  */
  6.  
  7. #ifndef _sparc_reg_h
  8. #define    _sparc_reg_h
  9.  
  10. #ifdef KERNEL
  11. /*
  12.  * Location of the users' stored
  13.  * registers relative to R0.
  14.  * Usage is u.u_ar0[XX].
  15.  */
  16. #define    PSR    (0)
  17. #define    PC    (1)
  18. #define    nPC    (2)
  19. #define    SPARC_Y    (3)
  20. #define    G1    (4)
  21. #define    G2    (5)
  22. #define    G3    (6)
  23. #define    G4    (7)
  24. #define    G5    (8)
  25. #define    G6    (9)
  26. #define    G7    (10)
  27. #define    O0    (11)
  28. #define    O1    (12)
  29. #define    O2    (13)
  30. #define    O3    (14)
  31. #define    O4    (15)
  32. #define    O5    (16)
  33. #define    O6    (17)
  34. #define    O7    (18)
  35.  
  36. /* the following defines are for portability */
  37. #define    PS    PSR
  38. #define    SP    O6
  39. #define    R0    O0
  40. #define    R1    O1
  41.  
  42. #endif KERNEL
  43.  
  44.  
  45. /*
  46.  * And now for something completely the same...
  47.  */
  48. #ifndef __ASSEMBLER__
  49. struct regs {
  50.     int    r_psr;        /* processor status register */
  51.     int    r_pc;        /* program counter */
  52.     int    r_npc;        /* next program counter */
  53.     int    r_y;        /* the y register */
  54.     int    r_g1;        /* user global regs */
  55.     int    r_g2;
  56.     int    r_g3;
  57.     int    r_g4;
  58.     int    r_g5;
  59.     int    r_g6;
  60.     int    r_g7;
  61.     int    r_o0;
  62.     int    r_o1;
  63.     int    r_o2;
  64.     int    r_o3;
  65.     int    r_o4;
  66.     int    r_o5;
  67.     int    r_o6;
  68.     int    r_o7;
  69. };
  70.  
  71. #define    r_ps    r_psr        /* for portablility */
  72. #define    r_r0    r_o0
  73. #define    r_sp    r_o6
  74.  
  75. #endif !__ASSEMBLER__
  76.  
  77. /*
  78.  * Floating point definitions.
  79.  */
  80.  
  81. #define    FPU            /* we have an external float unit */
  82.  
  83. #ifndef __ASSEMBLER__
  84.  
  85. #define    FQ_DEPTH    16        /* maximum instuctions in FQ */
  86.  
  87. /*
  88.  * struct fpu_status is the floating point processor state
  89.  * struct fpu is the sum total of all possible floating point state
  90.  * which includes the state of external floating point hardware,
  91.  * fpa registers, etc..., if it exists.
  92.  */
  93. struct fpq {
  94.     unsigned long *addr;        /* address */
  95.     unsigned long instr;        /* instruction */
  96. };
  97. struct    fq {
  98.     union {                /* FPU inst/addr queue */
  99.         double    whole;
  100.         struct  fpq fpq;
  101.     } FQu;
  102. };
  103.  
  104.  
  105. #define    FPU_REGS_TYPE unsigned
  106. #define    FPU_FSR_TYPE unsigned
  107.  
  108. struct    fpu {
  109.     union {                 /* FPU floating point regs */
  110.         FPU_REGS_TYPE Fpu_regs[32];    /* 32 singles */
  111.         double    Fpu_dregs[16];        /* 16 doubles */
  112.     } fpu_fr;
  113.     FPU_FSR_TYPE Fpu_fsr;        /* FPU status register */
  114.     unsigned Fpu_flags;        /* control flags */
  115.     unsigned Fpu_extra;        /* extra word */
  116.     unsigned Fpu_qcnt;        /* count of valid entries in fps_q */
  117.     struct fq Fpu_q[FQ_DEPTH];    /* FPU instruction address queue */
  118. };
  119.  
  120. #define    fpu_regs    fpu_fr.Fpu_regs
  121. #define    fpu_dregs    fpu_fr.Fpu_dregs
  122. #define    fpu_fsr        Fpu_fsr
  123. #define    fpu_flags    Fpu_flags
  124. #define    fpu_extra    Fpu_extra
  125. #define    fpu_q        Fpu_q
  126. #define    fpu_qcnt    Fpu_qcnt
  127.  
  128. #endif !__ASSEMBLER__
  129.  
  130.  
  131. /*
  132.  * Definition of bits in the Sun-4 FSR (Floating-point Status Register)
  133.  *   ________________________________________________________________________
  134.  *  |  RD |  RP | TEM | NS | res | vers | FTT | QNE | PR | FCC | AEXC | CEXC |
  135.  *  |-----|---- |-----|----|-----|------|-----|-----|----|-----|------|------|
  136.  *   31 30 29 28 27 23  22  21 20 19  17 16 14   13   12  11 10 9    5 4    0
  137.  */
  138. #define    FSR_CEXC    0x0000001f    /* Current Exception */
  139. #define    FSR_AEXC    0x000003e0    /* ieee accrued exceptions */
  140. #define    FSR_FCC        0x00000c00    /* Floating-point Condition Codes */
  141. #define    FSR_PR        0x00001000    /* Partial Remainder */
  142. #define    FSR_QNE        0x00002000    /* Queue not empty */
  143. #define    FSR_FTT        0x0001c000    /* Floating-point Trap Type */
  144. #define FSR_VERS    0x000e0000    /* version field */
  145. #define FSR_RESV    0x00300000    /* reserved */
  146. #define FSR_NS        0x00400000    /* non-standard fp */
  147. #define FSR_TEM        0x0f800000    /* ieee Trap Enable Mask */
  148. #define    FSR_RP        0x30000000    /* Rounding Precision */
  149. #define    FSR_RD        0xc0000000    /* Rounding Direction */
  150.  
  151. #define FSR_VERS_SHIFT    (17)        /* amount to shift version field */
  152.  
  153. /*
  154.  * Definition of CEXC (Current EXCeption) bit field of fsr
  155.  */
  156. #define    FSR_CEXC_NX    0x00000001    /* inexact */
  157. #define    FSR_CEXC_DZ    0x00000002    /* divide-by-zero */
  158. #define    FSR_CEXC_UF    0x00000004    /* underflow */.
  159. #define    FSR_CEXC_OF    0x00000008    /* overflow */
  160. #define    FSR_CEXC_NV    0x00000010    /* invalid */
  161.  
  162. /*
  163.  * Definition of AEXC (Accrued EXCeption) bit field of fsr
  164.  */
  165. #define    FSR_AEXC_NX    (0x1 << 5)    /* inexact */
  166. #define    FSR_AEXC_DZ    (0x2 << 5)    /* divide-by-zero */
  167. #define    FSR_AEXC_UF    (0x4 << 5)    /* underflow */.
  168. #define    FSR_AEXC_OF    (0x8 << 5)    /* overflow */
  169. #define    FSR_AEXC_NV    (0x10 << 5)    /* invalid */
  170.  
  171. /*
  172.  * Defintion of FTT (Floating-point Trap Type) field within the FSR
  173.  */
  174. #define    FTT_NONE    0        /* no excepitons */
  175. #define    FTT_IEEE    1        /* IEEE exception */
  176. #define    FTT_UNFIN    2        /* unfinished fpop */
  177. #define    FTT_UNIMP    3        /* unimplemented fpop */
  178. #define    FTT_SEQ        4        /* sequence error */
  179. #define    FTT_ALIGN    5    /* alignment, by software convention */
  180. #define    FTT_DFAULT    6    /* data fault, by software convention */
  181. #define    FSR_FTT_SHIFT    14    /* shift needed to justfy ftt field */
  182. #define    FSR_FTT_IEEE    (FTT_IEEE   << FSR_FTT_SHIFT)
  183. #define    FSR_FTT_UNFIN    (FTT_UNFIN  << FSR_FTT_SHIFT)
  184. #define    FSR_FTT_UNIMP    (FTT_UNIMP  << FSR_FTT_SHIFT)
  185. #define    FSR_FTT_SEQ    (FTT_SEQ    << FSR_FTT_SHIFT)
  186. #define    FSR_FTT_ALIGN    (FTT_ALIGN  << FSR_FTT_SHIFT)
  187. #define    FSR_FTT_DFAULT    (FTT_DFAULT << FSR_FTT_SHIFT)
  188.  
  189. /*
  190.  * Values of VERS (version) field within the FSR
  191.  * NOTE: these values are overloaded; the cpu type must be used to
  192.  * further discriminate amongst these.  For that reason, no #defines are
  193.  * provided.
  194.  *
  195.  * Version    cpu = 21-22, 51-54        cpu = 23-24, 55-57
  196.  *    0    Weitek 1164/5 (FAB 1-4)        TI 8847
  197.  *    1    Weitek 1164/5 (FAB 5-6)        LSI L64814
  198.  *    2    TI 8847                TI TMS390C602A
  199.  *    3    Weitek 3170            Weitek 3171
  200.  *    4    Meiko                ?
  201.  *    5    ?                ?
  202.  *    6    ?                ?
  203.  *    7    No FP Hardware            No FP Hardware
  204.  */
  205.  
  206.  
  207. /*
  208.  * Definition of TEM (Trap Enable Mask) bit field of fsr
  209.  */
  210. #define    FSR_TEM_NX    (0x1 << 23)    /* inexact */
  211. #define    FSR_TEM_DZ    (0x2 << 23)    /* divide-by-zero */
  212. #define    FSR_TEM_UF    (0x4 << 23)    /* underflow */.
  213. #define    FSR_TEM_OF    (0x8 << 23)    /* overflow */
  214. #define    FSR_TEM_NV    (0x10 << 23)    /* invalid */
  215.  
  216. /*
  217.  * Definition of RP (Rounding Precision) field of fsr
  218.  */
  219. #define    RP_DBLEXT    0        /* double-extended */
  220. #define    RP_SINGLE    1        /* single */
  221. #define    RP_DOUBLE    2        /* double */
  222. #define    RP_RESERVED    3        /* unused and reserved */
  223.  
  224. /*
  225.  * Defintion of RD (Rounding Direction) field of fsr
  226.  */
  227. #define    RD_NEAR        0        /* nearest or even if tie */
  228. #define    RD_ZER0        1        /* to zero */
  229. #define    RD_POSINF    2        /* positive infinity */
  230. #define    RD_NEGINF    3        /* negative infinity */
  231.  
  232. /*
  233.  * Definition of the FP enable flags of the pcb struct
  234.  * Normal operation, all flags are zero
  235.  */
  236. #define    FP_UNINITIALIZED    1
  237. #define    FP_STARTSIG        2
  238. #define    FP_DISABLE        4
  239. #define    FP_ENABLE        8
  240.  
  241. #ifndef __ASSEMBLER__
  242. /*
  243.  * How a register window looks on the stack.
  244.  */
  245. struct rwindow {
  246.     int    rw_local[8];        /* locals */
  247.     int    rw_in[8];        /* ins */
  248. };
  249.  
  250. #define    rw_fp    rw_in[6]        /* frame pointer */
  251. #define    rw_rtn    rw_in[7]        /* return address */
  252.  
  253. /*
  254.  * Definition of bits in the Sun-4 PSR (Processor Status Register)
  255.  *   ____________________________________________________________________
  256.  *  |    IMPL   | VER |  ICC | res | EC | EF |  PIL  | S | PS | ET | CWP |
  257.  *  |-----------|-----|------|-----|----|----|-------|---|----|----|-----|
  258.  *   31       28 27  24 23  20 19 14 13   12  11    8  7    6    5  4    0
  259.  */
  260.  
  261.  
  262. struct p_status {
  263.   union {
  264.     unsigned int psr;
  265.     struct {
  266.     unsigned int 
  267.     impl:4,
  268.     ver:4,
  269.     icc:4,
  270.     reserved:6,
  271.     ec:1,
  272.     ef:1,
  273.     pil:4,
  274.     s:1,
  275.     ps:1,
  276.     et:1,
  277.     cwp:5;
  278.       } psr_bits;
  279.   } PSRREG;
  280. };
  281.  
  282. #endif !__ASSEMBLER__
  283.  
  284. #endif /*!_sparc_reg_h*/
  285.